package cn.edu.jxyy.mybatistest.test;

import cn.edu.jxyy.mybatistest.Utils.MyBatisUtils;
import cn.edu.jxyy.mybatistest.mapper.StudentMapper;
import cn.edu.jxyy.mybatistest.pojo.Student;
import org.apache.ibatis.session.SqlSession;

public class Update_part12_2 {
    public static void main(String[] args) {
        SqlSession session = MyBatisUtils.getSession();
        StudentMapper mapper = session.getMapper(StudentMapper.class);
        Student student = new Student();
        student.setId(7);
        student.setName("小白");
        student.setAge(16);
        int nRow = mapper.updateStudent(student);
        if (nRow <= 0){
            System.out.println("更新失败");
        }else{
            System.out.println("更新成功");
        }
        session.commit();
        session.close();
    }
}
